package com.rc.web.controller;


import com.rc.common.annotate.WithoutTenant;
import com.rc.pojo.dto.collect.AddCollectDTO;
import com.rc.pojo.vo.collect.CollectVO;
import com.rc.web.service.CollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.hibernate.validator.constraints.Range;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 员工信息 控制层。
 *
 * @author sym
 * @since 2024-05-24
 */
@Api(tags = "收藏")
@RestController
@RequestMapping("/collect")
@RequiredArgsConstructor
@Validated
public class CollectController {
    private final CollectService collectService;

    @PostMapping
    @ApiOperation("添加")
    @WithoutTenant
    public void add(@Validated @RequestBody AddCollectDTO dto){
        collectService.add(dto);
    }

    @DeleteMapping
    @ApiOperation("取消")
    public void deleteOneByItemIdAndType(@NotNull @ApiParam("项目id") Long itemId,
                                      @NotNull @ApiParam("收藏类型") Integer type){
        collectService.deleteOneByItemIdAndType(itemId,type);
    }


    @GetMapping("/list")
    @ApiOperation("列表")
    public List<CollectVO> getList(@Range(min = 0,max = 3) @ApiParam("收藏类型 0农庄 1活动 2知识 3认养") Integer type){
        return collectService.getList(type);
    }
}
